<?php

namespace App\Http\Middleware;

use Closure;

class Cors
{
    /**
     * Handle an incoming request.
     *
     * @param \Illuminate\Http\Request $request
     * @param \Closure $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        $response = $next($request);
        $response->headers->add([
            'Access-Control-Allow-Origin' => '*',
            'Access-Control-Allow-Headers' => 'Origin, Content-Type, Cookie, Accept, AccessToken, Device, Terrace, Application,X-Requested-With,x-ui-request,lang',
            'Access-Control-Allow-Methods' => 'GET, POST, PATCH, PUT, OPTIONS',
        ]);

        return $response;

    }
}
